package HP;

import java.util.Arrays;
import java.util.Scanner;

public class OneStr {

    //方法一:
/*    public static void main(String[] args) {
        //String str = "abbcdgyhujiklo";
        System.out.println("input:");
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        char[] che_str = str.toCharArray();

        System.out.println("che_str = " + Arrays.toString(che_str));
        for (int i = 0; i < che_str.length; i++) {
            boolean flag = false;
            for (int j = 0; j <che_str.length; j++) {
                if (i!=j){
                    if (che_str[i]==che_str[j]){
                        flag = true;
                        break;
                    }
                }
            }
            if (flag == false) {
                System.out.println("che = " + che_str[i]);
            }
        }

    }*/

    //方法二:
    public static void main(String[] args) {
        String str  = "abbcd";
        char[] che_str = str.toCharArray();
        System.out.println("che_str = " + Arrays.toString(che_str));

        for (int i = 0; i < che_str.length; i++) {
            if(serch(che_str,che_str[i])){
            }else {
                System.out.println(che_str[i]);
            }
        }
    }

    //查找
    public static boolean serch(char[] che_str,char a){
        int x = 0;
        for (int i = 0; i < che_str.length; i++) {
            if (che_str[i]==a){
                x++;
            }
        }
        if (x>1){
            return true;
        }else {
            return false;
        }
    }

}

